<!--
 * @Date: 2023-11-18 13:43:19
 * @LastEditTime: 2024-01-10 14:38:52
 * @Description: content
-->
<template>
  <view class="content">
    <uni-nav-bar
      title="欧气券详情"
      color="#fff"
      backgroundColor="transparent"
      :border="false"
      :statusBar="true"
      :fixed="true"
      @clickLeft="$c.back()"
    >
      <view class="uni-nav-bar-l-icon" slot="left">
        <view class="uni-nav-bar-l-icon-left icon">
          <image :src="$img('/static/img2/cc20.png')" lazy-load></image>
        </view>
      </view>
    </uni-nav-bar>

    <view v-if="pageData" class="coupon-item">
      <view class="coin">
        <image :src="pageData.level_img" mode="aspectFit" lazy-load></image>
      </view>

      <view class="info">
        <view class="title">{{ pageData.level_text }}</view>

        <view class="num">需要{{ pageData.kl_num2 }}个参与者</view>
      </view>

      <view v-if="true" class="share-ing">
        <view class="share-num">
          <text>
            {{ pageData.yl_count == pageData.kl_num2 ? '已结束' : '分享中' }}
          </text>

          {{ pageData.yl_count }}/{{ pageData.kl_num2 }}
        </view>

        <view class="progress">
          <cmd-progress
            :percent="(pageData.yl_count / pageData.kl_num2) * 100"
            :show-info="false"
            stroke-color=" linear-gradient(90deg, #E4690D 0%, #E40D1D 100%)"
            :strokeWidth="5"
          ></cmd-progress>
        </view>
      </view>

      <view v-else class="share-end">已结束</view>
    </view>

    <view
      v-if="pageData"
      class="hd-card common_bg"
      :style="{
        backgroundImage: `url(${$img('/static/img2/cc160.png')})`
      }"
    >
      <view class="title">您参与的{{ pageData.level_text }}共获得</view>

      <view class="num">
        <view class="icon">
          <image :src="$img('/static/img2/cc159.png')" lazy-load></image>
        </view>

        {{ pageData.yl_integral_count }}
      </view>

      <view class="join">
        <template v-if="pageData.yl_count < pageData.kl_num2">
          只要再邀请{{
            pageData.kl_num2 * 1 - pageData.yl_count * 1
          }}位参与者就能开券
        </template>

        <template v-else>已全部领取</template>
      </view>

      <view class="share-btn realative">
        <button class="hide" open-type="share"></button>
        <image :src="$img('/static/img2/cc169.png')" lazy-load></image>

        <!-- 分享好友 -->
      </view>
    </view>

    <view v-if="pageData" class="leader">
      <view class="avatar">
        <image :src="pageData.share_user_headimg" lazy-load></image>
      </view>

      <view class="info">
        <view class="name hang1">
          {{ pageData.share_user_nickname }}
        </view>

        <view class="time">{{ pageData.share_time }}</view>
      </view>

      <view class="money-status">
        <view class="money">{{ pageData.own2 }}</view>

        <view class="status">已领取</view>
      </view>
    </view>

    <view v-if="pageData" class="join-list">
      <view class="list-hd">
        <view class="title">参与列表</view>

        <view class="num">
          已参与

          <text>{{ pageData.yl_count }}/{{ pageData.kl_num2 }}</text>
        </view>
      </view>

      <view class="list-item" v-for="(item, i) in pageData.yl_list" :key="i">
        <view v-if="item.lucky_king == 1" class="win">手气最佳</view>

        <view class="avatar">
          <image :src="item.headimg" lazy-load></image>
        </view>

        <view class="info">
          <view class="name hang1">
            {{ item.nickname }}
          </view>

          <view class="time">{{ item.addtime }}</view>
        </view>

        <view class="money-status">
          <view class="money">{{ item.l_num }}</view>

          <view class="status">已领取</view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      optData: '',
      pageData: ''
    }
  },

  onShareAppMessage(e) {
    const userInfo = uni.getStorageSync('userinfo')

    return {
      title: `快来领取${userInfo.nickname}分享的${this.pageData.num}幸运币的${this.pageData.level_text}`,
      imageUrl: this.pageData.level_img,
      path:
        '/pages/user/index' +
        this.$c.qs({
          ou_coupon_id: this.pageData.id
        })
    }
  },

  onLoad(options) {
    this.optData = options

    this.getData()
  },

  methods: {
    getData() {
      this.req({
        url: 'coupon_detail',
        data: {
          coupon_id: this.optData.id
        },
        success: res => {
          if (res.status == 1) {
            this.pageData = res.data

            // this.pageData = {
            //   yl_list: [
            //     {
            //       lucky_king: 1,
            //       headimg: this.$img('/static/zzz.png'),
            //       nickname: '正正正正正正正正正正正正正正正正正正正正',
            //       addtime: '2333-23-23 23:23:23',
            //       l_num: 233
            //     },
            //     {
            //       lucky_king: 2,
            //       headimg: this.$img('/static/zzz.png'),
            //       nickname: '正正正正正正正正正正正正正正正正正正正正',
            //       addtime: '2333-23-23 23:23:23',
            //       l_num: 233
            //     }
            //   ]
            // }
          }
        }
      })
    }
  }
}
</script>

<style lang="scss">
.content {
  padding-bottom: 30rpx;

  image {
    width: 100%;
    height: 100%;
    border-radius: inherit;
  }

  .icon {
    display: flex;
    justify-content: center;
    align-items: center;
  }

  .coupon-item {
    margin: 20rpx auto 0;
    width: 690rpx;
    height: 142rpx;
    background: #252525;
    border: 2rpx solid #444444;
    box-sizing: border-box;
    padding: 30rpx;
    display: flex;
    align-items: center;
    position: relative;

    .coin {
      width: 122rpx;
      height: 122rpx;
      position: relative;
      // z-index: 1;

      image {
        width: 100%;
        height: 100%;
      }
    }

    .info {
      flex: 1;
      padding-left: 30rpx;

      .title {
        font-family: PingFang SC, PingFang SC;
        font-weight: 400;
        font-size: 26rpx;
        color: #ffffff;
      }

      .open-num {
        margin-top: 6rpx;

        font-family: PingFang SC, PingFang SC;
        font-weight: 400;
        font-size: 22rpx;
        color: #999999;
      }

      .num {
        margin-top: 6rpx;

        font-family: PingFang SC, PingFang SC;
        font-weight: 400;
        font-size: 22rpx;
        color: #999999;
      }
    }

    .share-btn {
      width: 132rpx;
      height: 52rpx;
      display: flex;
      justify-content: center;
      align-items: center;
    }

    .share-ing {
      display: flex;
      flex-flow: column nowrap;
      align-items: center;

      .share-num {
        display: flex;
        align-items: center;

        font-size: 24rpx;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #ffffff;

        text {
          color: #e40d1d;
        }
      }

      .progress {
        width: 150rpx;
        margin-top: 10rpx;

        /deep/.cmd-progress-inner {
          background-color: rgba(255, 255, 255, 0.2);
        }
      }
    }

    .share-end {
      padding-right: 20rpx;

      font-size: 24rpx;
      font-family: Source Han Sans CN;
      font-weight: 400;
      color: #dddddd;
    }
  }

  .hd-card {
    margin: 20rpx auto 0;
    width: 690rpx;
    height: 192rpx;
    display: flex;
    flex-flow: column nowrap;
    align-items: flex-start;
    justify-content: center;
    box-sizing: border-box;
    padding: 0 30rpx;
    position: relative;

    .title {
      font-family: PingFang SC, PingFang SC;
      font-weight: 400;
      font-size: 28rpx;
      color: #ffffff;
    }

    .num {
      display: flex;
      align-items: center;
      margin: 10rpx 0;

      .icon {
        width: 38rpx;
        height: 38rpx;
        margin-right: 10rpx;
      }

      font-family: PingFang SC, PingFang SC;
      font-weight: 400;
      font-size: 30rpx;
      color: #fdf1d2;
    }

    .join {
      display: flex;
      align-items: center;

      font-family: PingFang SC, PingFang SC;
      font-weight: 400;
      font-size: 22rpx;
      color: #ffffff;
    }

    .share-btn {
      position: absolute;
      right: 40rpx;
      top: 50%;
      transform: translateY(-50%);
      width: 132rpx;
      height: 52rpx;
    }
  }

  .leader {
    margin: 20rpx auto 0;
    width: 690rpx;
    box-sizing: border-box;
    padding: 20rpx 30rpx;
    display: flex;
    align-items: center;
    background: #252525;
    border: 2rpx solid #444444;

    .avatar {
      width: 80rpx;
      height: 80rpx;
      background: #9d9d9d;
      border: 1px solid #cccccc;
      border-radius: 50%;
      overflow: hidden;

      image {
        width: 100%;
        height: 100%;
      }
    }

    .info {
      width: 300rpx;
      padding-left: 20rpx;

      .name {
        font-size: 28rpx;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #ffffff;
      }

      .time {
        font-family: PingFang SC, PingFang SC;
        font-weight: 400;
        font-size: 24rpx;
        color: #cccccc;
      }
    }

    .money-status {
      flex: 1;
      display: flex;
      flex-flow: column nowrap;
      align-items: flex-end;

      .money {
        font-family: PingFang SC, PingFang SC;
        font-weight: 400;
        font-size: 28rpx;
        color: #e40d1d;
      }

      .status {
        margin-top: 10rpx;

        font-family: PingFang SC, PingFang SC;
        font-weight: 400;
        font-size: 20rpx;
        color: #cccccc;
      }
    }
  }

  .join-list {
    width: 690rpx;
    margin: 30rpx auto 0;
    box-sizing: border-box;
    background: #222222;
    border: 4rpx solid #e40d1d;
    padding: 0 30rpx 10rpx;

    .list-hd {
      padding: 30rpx 0;
      display: flex;
      justify-content: space-between;
      align-items: center;

      .title {
        font-family: 光良酒-干杯体, 光良酒-干杯体;
        font-weight: 400;
        font-size: 28rpx;
        color: #e40d1d;
        text-shadow: 0 0 2px #ffffff, 0 0 2px #ffffff, 0 0 2px #ffffff,
          0 0 2px #ffffff;
      }

      .num {
        font-family: PingFang SC, PingFang SC;
        font-weight: 400;
        font-size: 24rpx;
        color: #ffffff;

        text {
          color: #e40d1d;
        }
      }
    }

    .list-item {
      margin-bottom: 20rpx;
      box-sizing: border-box;
      padding: 20rpx;
      display: flex;
      align-items: center;
      border-radius: 10rpx;
      position: relative;
      border-bottom: 1rpx solid #333333;

      .win {
        position: absolute;
        left: 0;
        top: 0;
        z-index: 1;
        padding: 0 10rpx;
        height: 34rpx;
        background: #e4690d;
        border-radius: 4rpx;
        display: flex;
        align-items: center;

        font-family: 光良酒-干杯体, 光良酒-干杯体;
        font-weight: 400;
        font-size: 20rpx;
        color: #ffffff;
      }

      .avatar {
        width: 80rpx;
        height: 80rpx;
        background: #d8d8d8;
        border-radius: 50%;
        overflow: hidden;

        image {
          width: 100%;
          height: 100%;
        }
      }

      .info {
        width: 300rpx;
        padding-left: 20rpx;

        .name {
          font-size: 24rpx;
          font-family: Source Han Sans CN;
          font-weight: 400;
          color: #ffffff;
        }

        .time {
          font-family: PingFang SC, PingFang SC;
          font-weight: 400;
          font-size: 24rpx;
          color: #cccccc;
        }
      }

      .money-status {
        flex: 1;
        display: flex;
        flex-flow: column nowrap;
        align-items: flex-end;

        .money {
          font-family: PingFang SC, PingFang SC;
          font-weight: 400;
          font-size: 28rpx;
          color: #e40d1d;
        }

        .status {
          margin-top: 10rpx;

          font-family: PingFang SC, PingFang SC;
          font-weight: 400;
          font-size: 20rpx;
          color: #cccccc;
        }
      }
    }
  }
}
</style>
